<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/style/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="/style/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script type="text/javascript" src="/js/plugins/artDialog/jquery.artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/js/commonAll.js"></script>
    <title>PSS-订单管理</title>
    <style>
        .alt td {
            background: black !important;
        }
    </style>
    <script>
        $(function () {
            $("[name=beginDate]").click(function () {
                WdatePicker({readonly: true,
                    maxDate:$("[name=endDate]").val()
                });
            });
            $("[name=endDate]").click(function () {
                WdatePicker({readonly: true,
                    minDate:$("[name=beginDate]").val()
                });
            });
            $(".btn_audit").click(function () {
                var url = $(this).data("url");
                $.dialog({
                    title: "温馨提示",
                    content: "确定要审核吗?",
                    ok: function () {
                        $.get(url, function (data) {
                            if (data.success) {
                                $.dialog({
                                    title: "温馨提示",
                                    content: data.msg,
                                    ok: function () {
                                        location.reload();
                                    }
                                })
                            } else {
                                $.dialog({
                                    title: "温馨提示",
                                    content: data.msg,
                                    ok: true
                                })
                            }
                        })
                    },
                   cancel: true
                })
            });
        })
    </script>
</head>
<body>
<form id="searchForm" action="/orderBill/list" method="post">
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                    <div id="box_top">搜索</div>
                    <div id="box_center">
                        <fmt:formatDate value="${qo.beginDate}" pattern="yyyy-MM-dd" var="beginDate"></fmt:formatDate>
                        开始时间<input name="beginDate" value="${beginDate}" class="ui_input_txt02 Wdate"/>
                        <fmt:formatDate value="${qo.endDate}" pattern="yyyy-MM-dd" var="endDate"></fmt:formatDate>
                        结束时间<input name="endDate" value="${endDate}" class="ui_input_txt02 Wdate"/>
                        供应商
                        <select name="supplierId" class="ui_select01">
                            <option value="-1">所有供应商</option>
                            <c:forEach items="${suppliers}" var="item">
                                <option value="${item.id}" ${item.id == qo.supplierId ? "selected" : ''}>${item.name}</option>
                            </c:forEach>
                        </select>
                        状态
                        <select name="status" class="ui_select01">
                            <option value="-1" ${qo.status==-1 ? 'selected' : ''}>所有状态</option>
                            <option value="0" ${qo.status==0 ? 'selected' : ''}>未审核</option>
                            <option value="1" ${qo.status==1 ? 'selected' : ''}>已审核</option>
                        </select>
                        <input type="button" value="查询" class="ui_input_btn01 btn_page" data-page="1"/>
                    </div>
                    <div id="box_bottom">
                        <input type="button" value="新增" class="ui_input_btn01 btn_redirect"
                               data-url="/orderBill/input"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        <th width="30"><input type="checkbox" id="all"/></th>
                        <th>订单编码</th>
                        <th>业务时间</th>
                        <th>供应商</th>
                        <th>总金额</th>
                        <th>总数量</th>
                        <th>录入人</th>
                        <th>审核人</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    <tbody>
                    <c:forEach items="${pageResult.list}" var="item">
                        <tr>
                            <td><input type="checkbox" name="IDCheck" class="acb"/></td>
                            <td>${item.id}</td>
                            <td><fmt:formatDate value="${item.vdate}"></fmt:formatDate></td>
                            <td>${item.supplier.name}</td>
                            <td>${item.totalAmount}</td>
                            <td>${item.totalNumber}</td>
                            <td>${item.inputUser.name}</td>
                            <td>${item.auditor.name}</td>
                            <c:choose>
                                <c:when test="${item.status == 1}">
                                    <td><span style="color: green">已审核</span></td>
                                </c:when>
                                <c:otherwise>
                                    <td><span style="color: red">待审核</span></td>
                                </c:otherwise>
                            </c:choose>
                            <td>
                                <c:choose>
                                    <c:when test="${item.status == 0}">
                                        <a href="javascript:;" class="btn_redirect"
                                           data-url="/orderBill/input?id=${item.id}">编辑</a>
                                        <a href="javascript:;" class="btn_delete"
                                           data-url="/orderBill/delete?id=${item.id}">删除</a>
                                        <a href="javascript:;" class="btn_audit"
                                           data-url="/orderBill/audit?id=${item.id}">审核</a>
                                    </c:when>
                                    <c:otherwise>
                                        <a href="/orderBill/view?id=${item.id}">查看</a>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <div class="ui_tb_h30">
                <%@include file="../commons/common_page.jsp" %>
            </div>
        </div>
    </div>
</form>
</body>
</html>

